<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j" template="/layout/template.xhtml">

	<ui:define name="body">
		<h1>#{projetoHome.managed?'Editar':'Novo'} Projeto</h1>
		<h:form id="projeto" styleClass="edit">

			<rich:panel>
				<f:facet name="header">Termo de Abertura de Projeto</f:facet>

				<h:panelGrid columns="2" columnClasses="">

					<s:decorate id="nomeField" template="/layout/edit.xhtml">
						<ui:define name="label">Nome do Projeto</ui:define>
						<h:inputText id="nome" size="15"
							value="#{projetoHome.instance.nome}" />
					</s:decorate>

					<s:decorate id="clienteField" template="/layout/edit.xhtml">
						<ui:define name="label">Cliente</ui:define>
						<h:inputText id="cliente" size="15"
							value="#{projetoHome.instance.cliente}" />
					</s:decorate>

					<s:decorate id="orcamentoField" template="/layout/edit.xhtml">
						<ui:define name="label">Orcamento Previsto</ui:define>
						<h:inputText id="orcamento"
							value="#{projetoHome.instance.orcamento}">
							<a:support event="onblur" reRender="orcamentoField"
								bypassUpdates="true" ajaxSingle="true" />
						</h:inputText>
					</s:decorate>

					<s:decorate id="inicioField" template="/layout/edit.xhtml">
						<ui:define name="label">Inicio Previsto</ui:define>
						<rich:calendar id="inicio" required="true"
							value="#{projetoHome.instance.inicio}"
							datePattern="MM/dd/yyyy hh:mm a" />
					</s:decorate>

					<s:decorate id="fimprevistoField" template="/layout/edit.xhtml">
						<ui:define name="label">Fim Previsto</ui:define>
						<rich:calendar id="fimprevisto"
							value="#{projetoHome.instance.fimprevisto}"
							datePattern="MM/dd/yyyy hh:mm a" />
					</s:decorate>

					<s:decorate id="stakeholdersField" template="/layout/display.xhtml">
						<ui:define name="label">Stakeholders</ui:define>
						<a4j:commandLink value="Adicionar"
							onclick="#{rich:component('usuarioSearch')}.show()" />
						<rich:dataList
							value="#{projetoHome.instance.stakeholders.toArray()}" var="_stk">
							<h:outputText value="#{_stk}" />
						</rich:dataList>
					</s:decorate>

				</h:panelGrid>

				<s:decorate id="resumoField" template="/layout/edit.xhtml">
					<ui:define name="label">Resumo das condições do projeto</ui:define>
					<h:inputTextarea id="resumo" cols="90" rows="5"
						value="#{projetoHome.instance.resumo}" />
				</s:decorate>

				<s:decorate id="justificativaField" template="/layout/edit.xhtml">
					<ui:define name="label">Justificativa do projeto</ui:define>
					<h:inputTextarea id="justificativa" cols="90" rows="5"
						value="#{projetoHome.instance.justificativa}" />
				</s:decorate>

				<s:decorate id="necessidadesField" template="/layout/edit.xhtml">
					<ui:define name="label">Necessidades básicas do trabalho a ser realizado</ui:define>
					<h:inputTextarea id="necessidades" cols="90" rows="5"
						value="#{projetoHome.instance.necessidades}" />
				</s:decorate>

				<s:decorate id="premissasField" template="/layout/edit.xhtml">
					<ui:define name="label">Premissas iniciais</ui:define>
					<h:inputTextarea id="premissas" cols="90" rows="5"
						value="#{projetoHome.instance.premissas}" />
				</s:decorate>

				<s:decorate id="restricoesField" template="/layout/edit.xhtml">
					<ui:define name="label">Restrições iniciais</ui:define>
					<h:inputTextarea id="restricoes" cols="90" rows="5"
						value="#{projetoHome.instance.restricoes}" />
				</s:decorate>

				<s:decorate id="produtoField" template="/layout/edit.xhtml">
					<ui:define name="label">Descrição do produto</ui:define>
					<h:inputTextarea id="produto" cols="90" rows="5"
						value="#{projetoHome.instance.produto}" />
				</s:decorate>

				<s:decorate id="responsabilidadesgpField"
					template="/layout/edit.xhtml">
					<ui:define name="label">Responsabilidades do gerente de projetos</ui:define>
					<h:inputTextarea id="responsabilidadesgp" cols="90" rows="5"
						value="#{projetoHome.instance.responsabilidadesgp}" />
				</s:decorate>

				<div style="clear: both">
					<span class="required">*</span> Campos obrigatórios
				</div>

			</rich:panel>

			<div class="actionButtons">

				<h:commandButton id="save" value="Salvar"
					action="#{projetoHome.persist}" disabled="#{!projetoHome.wired}"
					rendered="#{!projetoHome.managed}" />

				<h:commandButton id="update" value="Salvar"
					action="#{projetoHome.persist}" rendered="#{projetoHome.managed}" />

				<s:button id="cancelAdd" value="Cancelar" propagation="end"
					view="/view/home.xhtml" rendered="#{!projetoHome.managed}" />

			</div>
		</h:form>
		<rich:modalPanel id="usuarioSearch" autosized="true">
			<f:facet name="header">
				<h:panelGroup>
					<h:outputText value="Buscar Stakeholders"></h:outputText>
				</h:panelGroup>
			</f:facet>
			<f:facet name="controls">
				<h:panelGroup>
					<h:graphicImage value="/img/close.png" styleClass="hidelink"
						id="hidelink" />
					<rich:componentControl for="usuarioSearch" attachTo="hidelink"
						operation="hide" event="onclick" />
				</h:panelGroup>
			</f:facet>
			<h:form id="stkForm">
				<rich:panel>
					<f:facet name="header">Filtro de Busca</f:facet>
					<s:decorate template="/layout/display.xhtml">
						<ui:define name="label">Email</ui:define>
						<h:inputText id="email" value="#{usuarioList.usuario.email}" />
					</s:decorate>

					<s:decorate template="/layout/display.xhtml">
						<ui:define name="label">Endereco</ui:define>
						<h:inputText id="endereco" value="#{usuarioList.usuario.endereco}" />
					</s:decorate>

					<s:decorate template="/layout/display.xhtml">
						<ui:define name="label">Login</ui:define>
						<h:inputText id="login" value="#{usuarioList.usuario.login}" />
					</s:decorate>
				</rich:panel>
				<h:panelGrid>
					<div class="actionButtons">
						<h:commandButton id="buscar" value="buscar">
							<a4j:support event="oncomplete" reRender="stkForm,usuarioList" />
						</h:commandButton>
					</div>
				</h:panelGrid>
			</h:form>
			<a4j:outputPanel id="usuarioList">
				<rich:dataTable var="_usuario" value="#{usuarioList.resultList}"
					rendered="#{not empty usuarioList.resultList}">
					<h:column>
						<f:facet name="header">
							<ui:include src="/layout/sort.xhtml">
								<ui:param name="entityList" value="#{usuarioList}" />
								<ui:param name="propertyLabel" value="Id Usuário" />
								<ui:param name="propertyPath" value="usuario.id" />
							</ui:include>
						</f:facet>
						<h:outputText value="#{_usuario.id}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<ui:include src="/layout/sort.xhtml">
								<ui:param name="entityList" value="#{usuarioList}" />
								<ui:param name="propertyLabel" value="Nome" />
								<ui:param name="propertyPath" value="usuario.nome" />
							</ui:include>
						</f:facet>
						<h:outputText value="#{_usuario.nome}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<ui:include src="/layout/sort.xhtml">
								<ui:param name="entityList" value="#{usuarioList}" />
								<ui:param name="propertyLabel" value="Login" />
								<ui:param name="propertyPath" value="usuario.login" />
							</ui:include>
						</f:facet>
						<h:outputText value="#{_usuario.login}" />
					</h:column>

					<h:column>
						<f:facet name="header">
							<ui:include src="/layout/sort.xhtml">
								<ui:param name="entityList" value="#{usuarioList}" />
								<ui:param name="propertyLabel" value="Email" />
								<ui:param name="propertyPath" value="usuario.email" />
							</ui:include>
						</f:facet>
						<h:outputText value="#{_usuario.email}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<ui:include src="/layout/sort.xhtml">
								<ui:param name="entityList" value="#{usuarioList}" />
								<ui:param name="propertyLabel" value="Endereco" />
								<ui:param name="propertyPath" value="usuario.endereco" />
							</ui:include>
						</f:facet>
						<h:outputText value="#{_usuario.endereco}" />
					</h:column>
					<rich:column styleClass="action">
						<f:facet name="header">Action</f:facet>
						<h:form>
							<a4j:commandButton
								action="#{projetoHome.instance.stakeholders.add(_usuario)}"
								value="Adicionar" reRender="projeto" />
						</h:form>
					</rich:column>
				</rich:dataTable>
			</a4j:outputPanel>
		</rich:modalPanel>


	</ui:define>

</ui:composition>

